package br.ufmg.ubicomp.droidguide.context;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.RadioButton;
import br.ufmg.ubicomp.droidguide.R;
import br.ufmg.ubicomp.droidguide.context.*;

	public class TimeAvailable extends Activity implements OnClickListener {
		
		RadioButton tenho15min;
		RadioButton tenho30min;
		RadioButton tenhoUmaHora;
		RadioButton tenhoMaisHora;
		Button back;
		LogicContextDroidGuide lc;
		
		/** Called when the activity is first created. */
	    @Override
	    public void onCreate(Bundle icicle) {
	        super.onCreate(icicle);
	        setContentView(R.layout.timeavailable);
	        
					lc = new LogicContextDroidGuide();
					
					tenho15min    = (RadioButton)this.findViewById(R.id.tenho15min);
					tenho30min    = (RadioButton)this.findViewById(R.id.tenho30min);
					tenhoUmaHora  = (RadioButton)this.findViewById(R.id.tenhoUmaHora);
					tenhoMaisHora = (RadioButton)this.findViewById(R.id.tenhoMaisHora);
					
//					if ( lc.getTime() == 1 ){
//						tenho15min.setChecked(true);
//					}
//					else if  ( lc.getTime() == 2 ){
//						tenho30min.setChecked(true);
//					}
//					else if  ( lc.getTime() == 3 ){
//						tenhoUmaHora.setChecked(true);				
//					}
//					else if  ( lc.getTime() == 4 ){
//						tenhoMaisHora.setChecked(true);				
//					}
					
					
					back = (Button)this.findViewById(R.id.back);
					back.setOnClickListener(this);
	    }
	    
		public void onClick(View v) {
			if (tenho15min.isChecked()) {
				lc.setTime( 1 );
			}
			else if (tenho30min.isChecked()) {
				lc.setTime( 2 );
			}
			else if (tenhoUmaHora.isChecked()) {
				lc.setTime( 3 );
			}
			else if (tenhoMaisHora.isChecked()) {
				lc.setTime( 4 );
			}
			finish();

		}
	}
